



<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#FFF">
  <link rel="apple-touch-icon" sizes="180x180" href="/lostyu/images/apple-touch-icon.png">

<link rel="icon" type="image/ico" sizes="32x32" href="/lostyu/images/favicon.ico">
  <meta http-equiv="Cache-Control" content="no-transform">
  <meta http-equiv="Cache-Control" content="no-siteapp">


<link rel="alternate" type="application/rss+xml" title="Eden" href="https://luhongdeng.gitee.io/rss.xml" />
<link rel="alternate" type="application/atom+xml" title="Eden" href="https://luhongdeng.gitee.io/atom.xml" />
<link rel="alternate" type="application/json" title="Eden" href="https://luhongdeng.gitee.io/feed.json" />

<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Mulish:300,300italic,400,400italic,700,700italic%7CFredericka%20the%20Great:300,300italic,400,400italic,700,700italic%7CNoto%20Serif%20JP:300,300italic,400,400italic,700,700italic%7CNoto%20Serif%20SC:300,300italic,400,400italic,700,700italic%7CInconsolata:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">

<link rel="stylesheet" href="/lostyu/css/app.css?v=0.2.5">

  

<link rel="canonical" href="https://luhongdeng.gitee.io/2020/12/23/io%E6%B5%81%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C/">



  <title>
io流常用操作..o |
我的金子，只给千寻 = Eden</title>
<meta name="generator" content="Hexo 5.3.0"></head>
<body itemscope itemtype="http://schema.org/WebPage">
  <div id="loading">
    <div class="cat">
      <div class="body"></div>
      <div class="head">
        <div class="face"></div>
      </div>
      <div class="foot">
        <div class="tummy-end"></div>
        <div class="bottom"></div>
        <div class="legs left"></div>
        <div class="legs right"></div>
      </div>
      <div class="paw">
        <div class="hands left"></div>
        <div class="hands right"></div>
      </div>
    </div>
  </div>
  <div id="container">
    <header id="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="inner">
        <div id="brand">
          <div class="pjax">
          
  <h1 itemprop="name headline">io流常用操作..o
  </h1>
  
<div class="meta">
  <span class="item" title="Created: 2020-12-23 23:28:16">
    <span class="icon">
      <i class="ic i-calendar"></i>
    </span>
    <span class="text">Posted on</span>
    <time itemprop="dateCreated datePublished" datetime="2020-12-23T23:28:16+08:00">2020-12-23</time>
  </span>
</div>


          </div>
        </div>
        <nav id="nav">
  <div class="inner">
    <div class="toggle">
      <div class="lines" aria-label="Toggle navigation bar">
        <span class="line"></span>
        <span class="line"></span>
        <span class="line"></span>
      </div>
    </div>
    <ul class="menu">
      <li class="item title"><a href="/lostyu/" rel="start">我的金子，只给千寻</a></li>
    </ul>
    <ul class="right">
      <li class="item theme">
        <i class="ic i-sun"></i>
      </li>
      <li class="item search">
        <i class="ic i-search"></i>
      </li>
    </ul>
  </div>
</nav>

      </div>
      <div id="imgs" class="pjax">
        <ul>
          <li class="item" data-background-image="https://tva4.sinaimg.cn/large/6833939bly1giclg5ms2rj20zk0m8u0x.jpg"></li>
          <li class="item" data-background-image="https://tva4.sinaimg.cn/large/6833939bly1gicitspjpbj20zk0m81ky.jpg"></li>
          <li class="item" data-background-image="https://tva4.sinaimg.cn/large/6833939bly1gicljgocqbj20zk0m8e81.jpg"></li>
          <li class="item" data-background-image="https://tva4.sinaimg.cn/large/6833939bly1gipewr8iypj20zk0m8b29.jpg"></li>
          <li class="item" data-background-image="https://tva4.sinaimg.cn/large/6833939bly1giclj61ylzj20zk0m8b29.jpg"></li>
          <li class="item" data-background-image="https://tva4.sinaimg.cn/large/6833939bly1gicitcxhpij20zk0m8hdt.jpg"></li>
        </ul>
      </div>
    </header>
    <div id="waves">
      <svg class="waves" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto">
        <defs>
          <path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s 58 18 88 18 58-18 88-18 58 18 88 18 v44h-352z" />
        </defs>
        <g class="parallax">
          <use xlink:href="#gentle-wave" x="48" y="0" />
          <use xlink:href="#gentle-wave" x="48" y="3" />
          <use xlink:href="#gentle-wave" x="48" y="5" />
          <use xlink:href="#gentle-wave" x="48" y="7" />
        </g>
      </svg>
    </div>
    <main>
      <div class="inner">
        <div id="main" class="pjax">
          
  <div class="article wrap">
    
<div class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList">
<i class="ic i-home"></i>
<span><a href="/lostyu/">Home</a></span>
</div>

    <article itemscope itemtype="http://schema.org/Article" class="post block" lang="en">
  <link itemprop="mainEntityOfPage" href="https://luhongdeng.gitee.io/2020/12/23/io%E6%B5%81%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C/">

  <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
    <meta itemprop="image" content="/lostyu/images/avatar.jpg">
    <meta itemprop="name" content="Eden的个人世界">
    <meta itemprop="description" content=", ">
  </span>

  <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
    <meta itemprop="name" content="Eden">
  </span>

  <div class="body md" itemprop="articleBody">
    

    <p>I/O 输入 / 输出 (Input/Output)，分为 IO 设备和 IO 接口两个部分。 在 POSIX 兼容的系统上，例如 Linux 系统 [1]  ，I/O 操作可以有多种方式，比如 DIO (Direct I/O)，AIO (Asynchronous I/O，异步 I/O)，Memory-Mapped I/O (内存映射 I/O) 等，不同的 I/O 方式有不同的实现方式和性能，在不同的应用中可以按情况选择不同的 I/O 方式。</p>
<h4 id="一-什么是io流"><a class="markdownIt-Anchor" href="#一-什么是io流">#</a> 一、什么是 IO 流</h4>
<ul>
<li>IO 流用来处理设备之间的数据传输</li>
<li>Java 程序中对于数据的输入输出操作以 “流（Stream）” 的方式进行</li>
<li>java.io 包提供了各种的流类和接口，用以处理不同类型的数据，并通过标准的方法输入和输出数据</li>
</ul>
<ol>
<li>
<p>流的分类</p>
<ul>
<li>
<p>按操作数据单位不同分为：字节流（8bit）、字符流（16bit）</p>
</li>
<li>
<p>按数据流向流向不同分为：输入流和输出流</p>
</li>
<li>
<p>按照流的角色的不同分为：节点流、处理流</p>
<p><img data-src="image-20201128000955471.png" alt="image-20201128000955471"></p>
</li>
</ul>
<table>
<thead>
<tr>
<th style="text-align:left">抽象基类</th>
<th>字节流</th>
<th>字符流</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">输入流</td>
<td>InputStream</td>
<td>Reader</td>
</tr>
<tr>
<td style="text-align:left">输出流</td>
<td>OutputString</td>
<td>Writer</td>
</tr>
</tbody>
</table>
</li>
<li>
<p>常用的流的分类表</p>
<table>
<thead>
<tr>
<th><strong>分类</strong></th>
<th><strong>字节输入流</strong></th>
<th><strong>字节输出流</strong></th>
<th><strong>字符输入流</strong></th>
<th><strong>字符输出流</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td>抽象基类</td>
<td><em>InputStream</em></td>
<td><em>OutputStream</em></td>
<td><em>Reader</em></td>
<td><em>Writer</em></td>
</tr>
<tr>
<td>访问文件</td>
<td><strong>FileInputStream</strong></td>
<td><strong>FileOutputStream</strong></td>
<td><strong>FileReader</strong></td>
<td><strong>FileWriter</strong></td>
</tr>
<tr>
<td>访问数组</td>
<td><strong>ByteArrayInputStream</strong></td>
<td><strong>ByteArrayOutputStream</strong></td>
<td><strong>CharArrayReader</strong></td>
<td><strong>CharArrayWriter</strong></td>
</tr>
<tr>
<td>访问管道</td>
<td><strong>PipedInputStream</strong></td>
<td><strong>PipedOutputStream</strong></td>
<td><strong>PipedReader</strong></td>
<td><strong>PipedWriter</strong></td>
</tr>
<tr>
<td>访问字符串</td>
<td></td>
<td></td>
<td><strong>StringReader</strong></td>
<td><strong>StringWriter</strong></td>
</tr>
<tr>
<td>缓冲流</td>
<td>BufferedInputStream</td>
<td>BufferedOutputStream</td>
<td>BufferedReader</td>
<td>BufferedWriter</td>
</tr>
<tr>
<td>转换流</td>
<td></td>
<td></td>
<td>InputStreamReader</td>
<td>OutputStreamWriter</td>
</tr>
<tr>
<td>对象流</td>
<td>ObjectInputStream</td>
<td>ObjectOutputStream</td>
<td></td>
<td></td>
</tr>
<tr>
<td>抽象基类</td>
<td><em>FilterInputStream</em></td>
<td><em>FilterOutputStream</em></td>
<td><em>FilterReader</em></td>
<td><em>FilterWriter</em></td>
</tr>
<tr>
<td>打印流</td>
<td></td>
<td>PrintStream</td>
<td></td>
<td>PrintWriter</td>
</tr>
<tr>
<td>推回输入流</td>
<td>PushbackInputStream</td>
<td></td>
<td>PushbackReader</td>
<td></td>
</tr>
<tr>
<td>特殊流</td>
<td>DataInputStream</td>
<td>DataOutputStream</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
<blockquote>
<p>表中粗体字所标出的类代表节点流，必须直接与指定的物理节点关联。斜体字标出的类代表抽象基类，无法直接创建实例</p>
</blockquote>
</li>
</ol>
<h3 id="二-常用的io流的用法"><a class="markdownIt-Anchor" href="#二-常用的io流的用法">#</a> 二、常用的 io 流的用法</h3>
<ol>
<li>
<p>File 类</p>
<ol>
<li>
<p>构造方法</p>
<blockquote>
<p>File (String pathname)：通过给定路径名字符串转换为抽象路径名来创建一个新 File 实例；</p>
<p>File (String parent, String child)：根据 parent 路径名字符串 和 child 路径名字符串，创建一个新 File 实例；</p>
<p>File (File parent, String child)：根据 parent 抽象路径名和 child 路径名字符串，创建一个 File 实例；</p>
</blockquote>
</li>
<li>
<p>File 类成员方法</p>
<ul>
<li>
<p>访问文件名</p>
<p>getName()</p>
<p>getPath()</p>
<p>getAbsolutePath()</p>
<p>getAbsoluteFile()</p>
<p>getParent()</p>
<p>renameTo(File newName)</p>
</li>
<li>
<p>文件检测</p>
<p>exists()</p>
<p>canWrite()</p>
<p>canRead()</p>
<p>isFile()</p>
<p>isDirectory()</p>
</li>
<li>
<p>获取常规文件信息</p>
<p>lastModified()</p>
<p>length()</p>
</li>
<li>
<p>目录操作相关</p>
<p>mkDir()</p>
<p>mkDirs()</p>
<p>list()</p>
<p>listFiles()</p>
</li>
<li>
<p>文件操作相关</p>
<p>createNewFile()</p>
<p>delete()</p>
</li>
</ul>
</li>
<li>
<p>示例</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">FileDemo</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        File dir = <span class="keyword">new</span> File(<span class="string">&quot;E:\\io&quot;</span>);</span><br><span class="line">        getAllDir(dir);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="comment">// 定义方法,实现目录的全遍历</span></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">getAllDir</span><span class="params">(File dir)</span> </span>&#123;</span><br><span class="line">        <span class="comment">//调用方法listFiles()对目录,dir进行遍历</span></span><br><span class="line">        File[] fileArr = dir.listFiles();</span><br><span class="line">        <span class="keyword">for</span>(File f : fileArr)&#123;</span><br><span class="line">            <span class="comment">//判断变量f表示的路径是不是文件夹,是，则递归遍历</span></span><br><span class="line">            <span class="keyword">if</span>(f.isDirectory())&#123;</span><br><span class="line">                getAllDir(f);</span><br><span class="line">            &#125;<span class="keyword">else</span>&#123;</span><br><span class="line">                System.out.println(f);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ol>
</li>
<li>
<p>文件流</p>
<ol>
<li>
<p>FileOutputStream 类</p>
<ol>
<li>
<p>构造方法</p>
<p>FileOutputStream (File file) ：创建一个向指定 File 对象表示的文件中写入数据的文件输出流。</p>
<p>FileOutputStream (File file, boolean append)： 创建一个向指定 File 对象表示的文件中写入数据的文件输出流，以追加的方式写入。</p>
<p>FileOutputStream (String name) ：创建一个向具有指定名称的文件中写入数据的输出文件流。</p>
<p>FileOutputStream (String name, boolean append) ：创建一个向具有指定 name 的文件中写入数据的输出文件流，以追加的方式写入。</p>
<blockquote>
<p>默认情况下，当一个文件输出流对象，指向一个文件的时候，会清空文件内容。FileOutputStream 的构造方法第二个参数中加入 true 实现追加</p>
</blockquote>
</li>
<li>
<p>流对象的使用</p>
<ul>
<li>
<p>创建流子类的对象，绑定数据目的</p>
</li>
<li>
<p>调用流对象的方法 write 写</p>
</li>
<li>
<p>close 释放资源</p>
<blockquote>
<p>流对象的构造方法，可以创建文件，如果文件存在，直接覆盖</p>
</blockquote>
</li>
</ul>
</li>
</ol>
</li>
<li>
<p>FileWriter 类</p>
<ol>
<li>
<p>FileInputStream(File file)</p>
<p>FileInputStream(String name)</p>
</li>
<li>
<p>字符输出流，写数据的时候，必须要运行 flush () 刷新功能</p>
</li>
</ol>
</li>
<li>
<p>FileInputStream 类</p>
<ol>
<li>
<p>构造方法</p>
<p>FileInputStream(File file)</p>
<p>FileInputStream(String name)</p>
</li>
<li>
<p>流对象的使用</p>
<ul>
<li>
<p>创建字节输入流的子类对象</p>
</li>
<li>
<p>调用读取方法 read 读取</p>
</li>
<li>
<p>close 释放资源</p>
<blockquote>
<p>在 read 读取的过程中可以使用一次读一个字节和一次读取一个字节数组两种方式</p>
</blockquote>
</li>
</ul>
</li>
</ol>
</li>
<li>
<p>FileReader 类</p>
<ol>
<li>
<p>构造方法</p>
<p>FileReader(String fileName)</p>
<p>FileWriter(File file, boolean append)</p>
</li>
<li>
<p>流对象的使用</p>
<ul>
<li>创建字节输入流的子类对象</li>
<li>调用读取方法 read 读取</li>
<li>close 释放资源</li>
</ul>
</li>
</ol>
<blockquote>
<p>FileInputStream 和 FileReader 使用 int read (byte [] b) 读取一个字节，读到结尾返回 - 1，可以使用 read (byte [] b, int off, int len) 读取多个字节存入数组中，数组的缓冲作用可以提高效率</p>
</blockquote>
<blockquote>
<p>write (byte [] b)： 将 b.length 个字节从指定的 byte 数组写入此输出流</p>
<p>write (byte [] b, int off, int len)：将指定 byte 数组中从偏移量 off 开始的 len 个字节写入此输出流。</p>
<p>write (int b)： 将指定的字节写入此输出流。</p>
</blockquote>
</li>
<li>
<p>示例</p>
<p>字节文本复制</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Copy_1</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        <span class="keyword">long</span> s = System.currentTimeMillis();</span><br><span class="line">        FileInputStream fis = <span class="keyword">null</span>;</span><br><span class="line">        FileOutputStream fos = <span class="keyword">null</span>;</span><br><span class="line">        <span class="keyword">try</span>&#123;</span><br><span class="line">            fis = <span class="keyword">new</span> FileInputStream(<span class="string">&quot;D:\\test.mp3&quot;</span>);</span><br><span class="line">            fos = <span class="keyword">new</span> FileOutputStream(<span class="string">&quot;E:\\test.mp3&quot;</span>);</span><br><span class="line">            <span class="comment">//定义字节数组,缓冲</span></span><br><span class="line">            <span class="keyword">byte</span>[] bytes = <span class="keyword">new</span> <span class="keyword">byte</span>[<span class="number">1024</span>*<span class="number">10</span>];</span><br><span class="line">            <span class="comment">//读取数组,写入数组</span></span><br><span class="line">            <span class="keyword">int</span> len = <span class="number">0</span> ;</span><br><span class="line">            <span class="keyword">while</span>((len = fis.read(bytes))!=-<span class="number">1</span>)&#123;</span><br><span class="line">                fos.write(bytes, <span class="number">0</span>, len);</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;<span class="keyword">catch</span>(IOException e)&#123;</span><br><span class="line">            System.out.println(e);</span><br><span class="line">            <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(<span class="string">&quot;文件复制失败&quot;</span>);</span><br><span class="line">        &#125;<span class="keyword">finally</span>&#123;</span><br><span class="line">            <span class="keyword">try</span>&#123;</span><br><span class="line">                <span class="keyword">if</span>(fos!=<span class="keyword">null</span>)</span><br><span class="line">                    fos.close();</span><br><span class="line">            &#125;<span class="keyword">catch</span>(IOException e)&#123;</span><br><span class="line">                <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(<span class="string">&quot;释放资源失败&quot;</span>);</span><br><span class="line">            &#125;<span class="keyword">finally</span>&#123;</span><br><span class="line">                <span class="keyword">try</span>&#123;</span><br><span class="line">                    <span class="keyword">if</span>(fis!=<span class="keyword">null</span>)</span><br><span class="line">                        fis.close();</span><br><span class="line">                &#125;<span class="keyword">catch</span>(IOException e)&#123;</span><br><span class="line">                    <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(<span class="string">&quot;释放资源失败&quot;</span>);</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">long</span> e = System.currentTimeMillis();</span><br><span class="line">        System.out.println(e-s);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>字符文本复制</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Copy_2</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> </span>&#123;</span><br><span class="line">        FileReader fr = <span class="keyword">null</span>;</span><br><span class="line">        FileWriter fw = <span class="keyword">null</span>;</span><br><span class="line">        <span class="keyword">try</span>&#123;</span><br><span class="line">            fr = <span class="keyword">new</span> FileReader(<span class="string">&quot;c:\\1.txt&quot;</span>);</span><br><span class="line">            fw = <span class="keyword">new</span> FileWriter(<span class="string">&quot;d:\\1.txt&quot;</span>);</span><br><span class="line">            <span class="keyword">char</span>[] cbuf = <span class="keyword">new</span> <span class="keyword">char</span>[<span class="number">1024</span>];</span><br><span class="line">            <span class="keyword">int</span> len = <span class="number">0</span> ;</span><br><span class="line">            <span class="keyword">while</span>(( len = fr.read(cbuf))!=-<span class="number">1</span>)&#123;</span><br><span class="line">                fw.write(cbuf, <span class="number">0</span>, len);</span><br><span class="line">                fw.flush();</span><br><span class="line">            &#125;</span><br><span class="line"></span><br><span class="line">        &#125;<span class="keyword">catch</span>(IOException ex)&#123;</span><br><span class="line">            System.out.println(ex);</span><br><span class="line">            <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(<span class="string">&quot;复制失败&quot;</span>);</span><br><span class="line">        &#125;<span class="keyword">finally</span>&#123;</span><br><span class="line">            <span class="keyword">try</span>&#123;</span><br><span class="line">                <span class="keyword">if</span>(fw!=<span class="keyword">null</span>)</span><br><span class="line">                    fw.close();</span><br><span class="line">            &#125;<span class="keyword">catch</span>(IOException ex)&#123;</span><br><span class="line">                <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(<span class="string">&quot;释放资源失败&quot;</span>);</span><br><span class="line">            &#125;<span class="keyword">finally</span>&#123;</span><br><span class="line">                <span class="keyword">try</span>&#123;</span><br><span class="line">                    <span class="keyword">if</span>(fr!=<span class="keyword">null</span>)</span><br><span class="line">                        fr.close();</span><br><span class="line">                &#125;<span class="keyword">catch</span>(IOException ex)&#123;</span><br><span class="line">                    <span class="keyword">throw</span> <span class="keyword">new</span> RuntimeException(<span class="string">&quot;释放资源失败&quot;</span>);</span><br><span class="line">                &#125;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ol>
</li>
<li>
<p>缓冲流</p>
<p>可提高 IO 流的读写速度<br>
分为字节缓冲流与字符缓冲流</p>
<ol>
<li>
<p>字节缓冲流 BufferedOutputStream / BufferedInputStream</p>
<ol>
<li>
<p>构造方法</p>
<p>BufferedOuputStream (OuputStream out)：可以传递任意的字节输出流</p>
<p>BufferedInputStream (InputStream in)：可以传递任意的字节输入流</p>
</li>
<li>
<p>写入 write 字节或 write 字节数组，read () 单个字节或字节数组</p>
</li>
</ol>
</li>
<li>
<p>字符缓冲流 BufferedWriter/ BufferedReader</p>
<ol>
<li>
<p>构造方法</p>
<p>BufferedWriter (Writer w)：传递任意字符输出流</p>
<p>BufferedReader (Reader r)：可以任意的字符输入流</p>
</li>
<li>
<p>写入 write 字节或 write 字节数组，read () 单个字节或字节数组</p>
</li>
<li>
<p>BufferedWriter— 特有方法 newLine 换行</p>
</li>
</ol>
<blockquote>
<p>在使用缓冲流后要关闭缓冲流，而且在关闭的同时也会关闭文件流</p>
</blockquote>
</li>
<li>
<p>示例</p>
<p>字节流文件复制</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Copy</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span><span class="keyword">throws</span> IOException </span>&#123;</span><br><span class="line">        <span class="keyword">long</span> s = System.currentTimeMillis();</span><br><span class="line">         BufferedInputStream bis = <span class="keyword">new</span> BufferedInputStream(<span class="keyword">new</span> FileInputStream(<span class="keyword">new</span> File(<span class="string">&quot;c:\\q.exe&quot;</span>)));</span><br><span class="line">         BufferedOutputStream bos = <span class="keyword">new</span> BufferedOutputStream(<span class="keyword">new</span> FileOutputStream(<span class="keyword">new</span> File(<span class="string">&quot;d:\\q.exe&quot;</span>)));</span><br><span class="line">        <span class="keyword">int</span> len = <span class="number">0</span> ;</span><br><span class="line">        <span class="keyword">byte</span>[] bytes = <span class="keyword">new</span> <span class="keyword">byte</span>[<span class="number">1024</span>];</span><br><span class="line">        <span class="keyword">while</span>((len = bis.read(bytes))!=-<span class="number">1</span>)&#123;</span><br><span class="line">            bos.write(bytes,<span class="number">0</span>,len);</span><br><span class="line">        &#125;</span><br><span class="line">        bos.close();</span><br><span class="line">        bis.close();</span><br><span class="line">        <span class="keyword">long</span> e = System.currentTimeMillis();</span><br><span class="line">        System.out.println(e-s);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>字符流文件复制</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Copy_1</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> <span class="keyword">throws</span> IOException</span>&#123;</span><br><span class="line">        BufferedReader bfr = <span class="keyword">new</span> BufferedReader(<span class="keyword">new</span> FileReader(<span class="string">&quot;c:\\w.log&quot;</span>));   </span><br><span class="line">        BufferedWriter bfw = <span class="keyword">new</span> BufferedWriter(<span class="keyword">new</span> FileWriter(<span class="string">&quot;d:\\w.log&quot;</span>));</span><br><span class="line">        <span class="comment">//读取文本行, 读一行,写一行,写换行</span></span><br><span class="line">        String line = <span class="keyword">null</span>;</span><br><span class="line">        <span class="keyword">while</span>((line = bfr.readLine())!=<span class="keyword">null</span>)&#123;</span><br><span class="line">            bfw.write(line);</span><br><span class="line">            bfw.newLine();</span><br><span class="line">            bfw.flush();</span><br><span class="line">        &#125;</span><br><span class="line">        bfw.close();</span><br><span class="line">        bfr.close();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ol>
</li>
<li>
<p>对象流</p>
<ul>
<li>对象的序列化：对象中的数据以流的形式写入到文件中保存过程称为写出对象</li>
<li>ObjectOutputStream 将对象写入文件中，实现序列化</li>
<li>对象的反序列化：在文件中以流的形式将对象读出来，读取对象</li>
<li>ObjectInputStream 将文件对象读取出来</li>
</ul>
<ol>
<li>
<p>构造方法</p>
<p>ObjectOutputStream (OutputSteam out)：传递任意的 字节输出流</p>
<p>ObjectInputStream (InputStream in)：传递任意的 字节输入流，输入流封装文件</p>
</li>
<li>
<p>writeObject (Object obj)：写出对象 ；Object readObject ()： 读取对象</p>
</li>
<li>
<p>示例</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">objectOutputStreamTest</span><span class="params">()</span> <span class="keyword">throws</span> IOException </span>&#123;</span><br><span class="line">    <span class="comment">// 1.创建字节输出流对象，封装文件</span></span><br><span class="line">    FileOutputStream fos = <span class="keyword">new</span> FileOutputStream(<span class="string">&quot;xuliehua.properties&quot;</span>);</span><br><span class="line">    <span class="comment">// 2.创建写出对象的序列化流的对象</span></span><br><span class="line">    ObjectOutputStream oos = <span class="keyword">new</span> ObjectOutputStream(fos);</span><br><span class="line">    Person per = <span class="keyword">new</span> Person(<span class="string">&quot;狂徒张三&quot;</span>, <span class="number">18</span>);</span><br><span class="line">    <span class="comment">// 3.调用序列化流的方法writeObject, 写出对象</span></span><br><span class="line">    oos.writeObject(per);</span><br><span class="line">    <span class="comment">// 4.关闭流操作</span></span><br><span class="line">    oos.close();</span><br><span class="line">    System.out.println(per.toString());</span><br><span class="line">&#125;</span><br><span class="line">      </span><br><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">objectInputStreamTest</span><span class="params">()</span> <span class="keyword">throws</span> IOException, ClassNotFoundException </span>&#123;</span><br><span class="line">    <span class="comment">// 1.创建字节输入流对象</span></span><br><span class="line">    FileInputStream fis = <span class="keyword">new</span> FileInputStream(<span class="string">&quot;xuliehua.properties&quot;</span>);</span><br><span class="line">    <span class="comment">// 2.创建反序列化流，构造方法中传递，字节输入流</span></span><br><span class="line">    ObjectInputStream ois = <span class="keyword">new</span> ObjectInputStream(fis);</span><br><span class="line">    <span class="comment">// 3.调用方法readObject()读取对象</span></span><br><span class="line">    Object obj = ois.readObject();</span><br><span class="line">    System.out.println(obj);</span><br><span class="line">    <span class="comment">// 4.关闭流操作</span></span><br><span class="line">    ois.close();</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ol>
</li>
<li>
<p>转换流</p>
<ol>
<li>
<p>构造方法</p>
<p>OutputStreamWriter (OuputStream out)：接收所有的字节输出流</p>
<p>OutputStreamWriter(OutputStream out, String charsetName)</p>
<blockquote>
<p>FileOutputStream</p>
</blockquote>
<p>InputStreamReader (InputStream in)：接收所有的 字节输入流</p>
<p>InputStreamReader (InputStream in,String charsetName) : 传递编码表的名字</p>
<blockquote>
<p>FileInputStream</p>
</blockquote>
</li>
<li>
<p>写入 write 字节或 write 字节数组，read () 单个字节或字节数组</p>
<blockquote>
<p>OutputStreamWriter 和 InputStreamReader 是字符和字节的桥梁：也可以称之为字符转换流。字符转换流原理：字节流 + 编码表</p>
<p>FileWriter\ 和 FileReader：作为子类，仅作为操作字符文件的便捷类存在。当操作的字符文件，使用的是默认编码表时可以不用父类，而直接用子类就完成操作了，简化了代码</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">InputStreamReader isr = <span class="keyword">new</span> InputStreamReader(<span class="keyword">new</span> FileInputStream(<span class="string">&quot;a.txt&quot;</span>));<span class="comment">//默认字符集。</span></span><br><span class="line">InputStreamReader isr = <span class="keyword">new</span> InputStreamReader(<span class="keyword">new</span> FileInputStream(<span class="string">&quot;a.txt&quot;</span>),<span class="string">&quot;GBK&quot;</span>);<span class="comment">//指定GBK字符集。</span></span><br><span class="line">FileReader fr = <span class="keyword">new</span> FileReader(<span class="string">&quot;a.txt&quot;</span>);</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li>
<p>示例</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">InputStreamReaderDemo</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> <span class="keyword">throws</span> IOException </span>&#123;</span><br><span class="line">        readUTF();</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="comment">//转换流,InputSteamReader读取文本，采用UTF-8编码表,读取文件utf</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">readUTF</span><span class="params">()</span><span class="keyword">throws</span> IOException</span>&#123;</span><br><span class="line">        <span class="comment">//创建字节输入流,传递文本文件</span></span><br><span class="line">        FileInputStream fis = <span class="keyword">new</span> FileInputStream(<span class="string">&quot;c:\\utf.txt&quot;</span>);</span><br><span class="line">        <span class="comment">//创建转换流对象,构造方法中,包装字节输入流,同时写编码表名</span></span><br><span class="line">        InputStreamReader isr = <span class="keyword">new</span> InputStreamReader(fis,<span class="string">&quot;UTF-8&quot;</span>);</span><br><span class="line">        <span class="keyword">char</span>[] ch = <span class="keyword">new</span> <span class="keyword">char</span>[<span class="number">1024</span>];</span><br><span class="line">        <span class="keyword">int</span> len = isr.read(ch);</span><br><span class="line">        System.out.println(<span class="keyword">new</span> String(ch,<span class="number">0</span>,len));</span><br><span class="line">        isr.close();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ol>
</li>
<li>
<p>打印流</p>
<ol>
<li>
<p>构造方法</p>
<p>PrintStream(OutputStream)</p>
<p>PrintWriter(OutputStream)</p>
</li>
<li>
<p>print (String str): 输出任意类型的数据；</p>
<p>println (String str): 输出任意类型的数据，自动写入换行操作</p>
</li>
<li>
<p>特点</p>
<ul>
<li>
<p>此流不负责数据源，只负责数据目的</p>
</li>
<li>
<p>可以操作任意类型的数据。（boolean， int， long， float， double）</p>
</li>
<li>
<p>打印流，可以开启自动刷新功能，满足两个条件：</p>
<ul>
<li>
<p>使用特定的构造方法，打开打印流的自动刷新，输出的数据目的必须是流对象：OutputStream Writer</p>
</li>
<li>
<p>必须调用 println，printf，format 三个方法中的一个，启用自动刷新</p>
</li>
</ul>
</li>
<li>
<p>使用特定的构造方法，打开打印流的自动刷新，输出的数据目的必须是流对象：OutputStream Writer</p>
</li>
<li>
<p>必须调用 println，printf，format 三个方法中的一个，启用自动刷新</p>
</li>
<li>
<p>为其他输出流，添加功能</p>
</li>
<li>
<p>永远不会抛出 IOException，但是可能抛出别的异常</p>
</li>
</ul>
</li>
</ol>
</li>
<li>
<p>示例</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">PrintWriterDemo1</span> </span>&#123;</span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">main</span><span class="params">(String[] args)</span> <span class="keyword">throws</span> IOException</span>&#123;</span><br><span class="line">        BufferedReader bfr = <span class="keyword">new</span> BufferedReader(<span class="keyword">new</span> FileReader(<span class="string">&quot;c:\\a.txt&quot;</span>));</span><br><span class="line">        PrintWriter pw = <span class="keyword">new</span> PrintWriter(<span class="keyword">new</span> FileWriter(<span class="string">&quot;d:\\a.txt&quot;</span>),<span class="keyword">true</span>);</span><br><span class="line">        String line = <span class="keyword">null</span>;</span><br><span class="line">        <span class="keyword">while</span>((line = bfr.readLine())!=<span class="keyword">null</span>)&#123;</span><br><span class="line">            pw.println(line);</span><br><span class="line">        &#125;</span><br><span class="line">        pw.close();</span><br><span class="line">        bfr.close();</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ol>

  </div>

   <footer>

    <div class="meta">
  <span class="item">
    <span class="icon">
      <i class="ic i-calendar-check"></i>
    </span>
    <span class="text">Edited on</span>
    <time title="Modified: 2020-12-24 00:20:01" itemprop="dateModified" datetime="2020-12-24T00:20:01+08:00">2020-12-24</time>
  </span>
</div>

      
<div class="reward">
  <button><i class="ic i-heartbeat"></i> Donate</button>
  <p>Give me a cup of [coffee]~(￣▽￣)~*</p>
  <div id="qr">
      
      <div>
        <img data-src="/lostyu/images/wechatpay.png" alt="Eden的个人世界 WeChat Pay">
        <p>WeChat Pay</p>
      </div>
      
      <div>
        <img data-src="/lostyu/images/alipay.png" alt="Eden的个人世界 Alipay">
        <p>Alipay</p>
      </div>
      
      <div>
        <img data-src="/lostyu/images/paypal.png" alt="Eden的个人世界 PayPal">
        <p>PayPal</p>
      </div>
  </div>
</div>

      

<div id="copyright">
<ul>
  <li class="author">
    <strong>Post author:  </strong>Eden的个人世界 <i class="ic i-at"><em>@</em></i>Eden
  </li>
  <li class="link">
    <strong>Post link: </strong>
    <a href="https://luhongdeng.gitee.io/2020/12/23/io%E6%B5%81%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C/" title="io流常用操作..o">https://luhongdeng.gitee.io/2020/12/23/io流常用操作/</a>
  </li>
  <li class="license">
    <strong>Copyright Notice:  </strong>All articles in this blog are licensed under <span class="exturl" data-url="aHR0cHM6Ly9jcmVhdGl2ZWNvbW1vbnMub3JnL2xpY2Vuc2VzL2J5LW5jLXNhLzQuMC9kZWVkLnpo"><i class="ic i-creative-commons"><em>(CC)</em></i>BY-NC-SA</span> unless stating additionally.
  </li>
</ul>
</div>

  </footer>

</article>

  </div>
  

<div class="post-nav">
    <div class="item left">
      

  <a href="/lostyu/2020/12/23/dubbo/" itemprop="url" rel="prev" data-background-image="https:&#x2F;&#x2F;tva4.sinaimg.cn&#x2F;mw690&#x2F;6833939bly1giciuv0socj20zk0m8qes.jpg" title="dubbo">
  <span class="type">Previous Post</span>
  <span class="category"><i class="ic i-flag"></i> </span>
  <h3>dubbo</h3>
  </a>

    </div>
    <div class="item right">
      

  <a href="/lostyu/2020/12/23/Java%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8B/" itemprop="url" rel="next" data-background-image="https:&#x2F;&#x2F;tva4.sinaimg.cn&#x2F;mw690&#x2F;6833939bly1giclh3brzpj20zk0m8ann.jpg" title="Java网络编程">
  <span class="type">Next Post</span>
  <span class="category"><i class="ic i-flag"></i> </span>
  <h3>Java网络编程</h3>
  </a>

    </div>
</div>

  
  <div class="wrap" id="comments"></div>


        </div>
        <div id="sidebar">
          

<div class="inner">

  <div class="panels">
    <div class="inner">
      <div class="contents panel pjax" data-title="Contents">
          <ol class="toc"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E4%B8%80-%E4%BB%80%E4%B9%88%E6%98%AFio%E6%B5%81"><span class="toc-number">1.</span> <span class="toc-text"> 一、什么是 IO 流</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%BA%8C-%E5%B8%B8%E7%94%A8%E7%9A%84io%E6%B5%81%E7%9A%84%E7%94%A8%E6%B3%95"><span class="toc-number"></span> <span class="toc-text"> 二、常用的 io 流的用法</span></a>
      </div>
      <div class="related panel pjax" data-title="Related">
      </div>
      <div class="overview panel" data-title="Overview">
        <div class="author" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <img class="image" itemprop="image" alt="Eden的个人世界"
      data-src="/lostyu/images/avatar.jpg">
  <p class="name" itemprop="name">Eden的个人世界</p>
  <div class="description" itemprop="description"></div>
</div>

<nav class="state">
    <div class="item posts">
      <a href="/lostyu/archives/">
        <span class="count">5</span>
        <span class="name">posts</span>
      </a>
    </div>
</nav>

<div class="social">
      <span class="exturl item github" data-url="aHR0cHM6Ly9naXRodWIuY29tL3lvdXJuYW1l" title="https:&#x2F;&#x2F;github.com&#x2F;yourname"><i class="ic i-github"></i></span>
      <span class="exturl item twitter" data-url="aHR0cHM6Ly90d2l0dGVyLmNvbS95b3VybmFtZQ==" title="https:&#x2F;&#x2F;twitter.com&#x2F;yourname"><i class="ic i-twitter"></i></span>
      <span class="exturl item zhihu" data-url="aHR0cHM6Ly93d3cuemhpaHUuY29tL3Blb3BsZS95b3VybmFtZQ==" title="https:&#x2F;&#x2F;www.zhihu.com&#x2F;people&#x2F;yourname"><i class="ic i-zhihu"></i></span>
      <span class="exturl item music" data-url="aHR0cHM6Ly9tdXNpYy4xNjMuY29tLyMvdXNlci9ob21lP2lkPXlvdXJpZA==" title="https:&#x2F;&#x2F;music.163.com&#x2F;#&#x2F;user&#x2F;home?id&#x3D;yourid"><i class="ic i-cloud-music"></i></span>
      <span class="exturl item weibo" data-url="aHR0cHM6Ly93ZWliby5jb20veW91cm5hbWU=" title="https:&#x2F;&#x2F;weibo.com&#x2F;yourname"><i class="ic i-weibo"></i></span>
      <span class="exturl item about" data-url="aHR0cHM6Ly9hYm91dC5tZS95b3VybmFtZQ==" title="https:&#x2F;&#x2F;about.me&#x2F;yourname"><i class="ic i-address-card"></i></span>
</div>

<ul class="menu">
  
    
  <li class="item">
    <a href="/lostyu/" rel="section"><i class="ic i-home"></i>Home</a>
  </li>


</ul>

      </div>
    </div>
  </div>

  <ul id="quick">
    <li class="prev pjax">
        <a href="/lostyu/2020/12/23/dubbo/" rel="prev" title="Previous Post"><i class="ic i-chevron-left"></i></a>
    </li>
    <li class="up"><i class="ic i-arrow-up"></i></li>
    <li class="down"><i class="ic i-arrow-down"></i></li>
    <li class="next pjax">
        <a href="/lostyu/2020/12/23/Java%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8B/" rel="next" title="Next Post"><i class="ic i-chevron-right"></i></a>
    </li>
    <li class="percent"></li>
  </ul>
</div>


        </div>
        <div class="dimmer"></div>
      </div>
    </main>
    <footer id="footer">
      <div class="inner">
        <div class="widgets">
          
<div class="rpost pjax">
  <h2>Random Posts</h2>
  <ul>
      
  <li class="item">
    
<div class="breadcrumb">
</div>

    <span><a href="/lostyu/2020/12/23/hello-world/" title="Hello World">Hello World</a></span>
  </li>

      
  <li class="item">
    
<div class="breadcrumb">
</div>

    <span><a href="/lostyu/2020/12/23/zookeeper/" title="zookeeper">zookeeper</a></span>
  </li>

      
  <li class="item">
    
<div class="breadcrumb">
</div>

    <span><a href="/lostyu/2020/12/23/io%E6%B5%81%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C/" title="io流常用操作..o">io流常用操作..o</a></span>
  </li>

      
  <li class="item">
    
<div class="breadcrumb">
</div>

    <span><a href="/lostyu/2020/12/23/Java%E7%BD%91%E7%BB%9C%E7%BC%96%E7%A8%8B/" title="Java网络编程">Java网络编程</a></span>
  </li>

      
  <li class="item">
    
<div class="breadcrumb">
</div>

    <span><a href="/lostyu/2020/12/23/dubbo/" title="dubbo">dubbo</a></span>
  </li>

  </ul>
</div>
<div>
  <h2>Recent Comments</h2>
  <ul class="leancloud-recent-comment"></ul>
</div>

        </div>
        <div class="status">
  <div class="copyright">
    
    &copy; 2010 – 
    <span itemprop="copyrightYear">2020</span>
    <span class="with-love">
      <i class="ic i-sakura rotate"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">Eden的个人世界 @ 我的金子，只给千寻</span>
  </div>
  <div class="powered-by">
    Powered by <span class="exturl" data-url="aHR0cHM6Ly9oZXhvLmlv">Hexo</span> & Theme.<span class="exturl" data-url="aHR0cHM6Ly9naXRodWIuY29tL2FtZWhpbWUvaGV4by10aGVtZS1zaG9rYQ==">Shoka</span>
  </div>
</div>

      </div>
    </footer>
  </div>
<script data-config type="text/javascript">
  var LOCAL = {
    path: '2020/12/23/io流常用操作/',
    favicon: {
      show: "（●´3｀●）Goooood",
      hide: "(´Д｀)Booooom"
    },
    search : {
      placeholder: "Search for Posts",
      empty: "We didn't find any results for the search: ${query}",
      stats: "${hits} results found in ${time} ms"
    },
    valine: true,fancybox: true,copyright: 'Copied to clipboard successfully! <br> All articles in this blog are licensed under <i class="ic i-creative-commons"></i>BY-NC-SA.',
    ignores : [
      function(uri) {
        return uri.includes('#');
      },
      function(uri) {
        return new RegExp(LOCAL.path+"$").test(uri);
      }
    ]
  };
</script>

<script src="https://cdn.polyfill.io/v2/polyfill.js"></script>

<script src="//cdn.jsdelivr.net/combine/npm/pace-js@1.0.2/pace.min.js,npm/pjax@0.2.8/pjax.min.js,npm/whatwg-fetch@3.4.0/dist/fetch.umd.min.js,npm/animejs@3.2.0/lib/anime.min.js,npm/algoliasearch@4/dist/algoliasearch-lite.umd.js,npm/instantsearch.js@4/dist/instantsearch.production.min.js,npm/lozad@1/dist/lozad.min.js,npm/quicklink@2/dist/quicklink.umd.js"></script>

<script src="/lostyu/js/app.js?v=0.2.5"></script>




</body>
</html>
